<template>
		<list :data="data" :pulldown="pulldown" @pulldown="loadData" v-if="showdata.length" >
	<div class="index__content__src-home-rankingFlowNormal- content">
			<a class="index__item__src-commonComponent-Item-" href="/video/av21707880.html" v-for="(item,index) in showdata">
				<div class="index__imgContainer__src-commonComponent-Item-">
					<img src="//s1.hdslb.com/bfs/static/mult/images/tv.png" class="index__tv__src-commonComponent-Item-" alt="">
					<img v-lazy="item.pic+'@320w_200h.webp'" :alt="item.title" class="index__normal__src-commonComponent-Item-">
					<div class="index__info__src-commonComponent-Item-">
						<div class="index__playIcon__src-commonComponent-Item-">
							<svg class="index__icon__src-commonComponent-Item-" aria-hidden="true">
								<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-bofangshu"></use>
							</svg>
						</div>
						<div class="index__play__src-commonComponent-Item-">
							<p>{{floor(item.play)+'万'}}</p>
						</div>
						<div class="index__danmuIcon__src-commonComponent-Item-">
							<svg class="index__icon__src-commonComponent-Item-" aria-hidden="true">
								<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-danmushu"></use>
							</svg>
						</div>
						<div class="index__view__src-commonComponent-Item-">
							<p>{{item.video_review}}</p>
						</div>
					</div>
				</div>
				<div class="index__title__src-commonComponent-Item-">
					<p>{{item.title}}</p>
				</div>
			</a>
			<div class="loading-wrapper"></div>
	</div>
		</list>
</template>

<script>
import axios from "axios";
import list from "components/content/list";
let doc="";
let dis=0;
let isAdd=true;
const listNum=20;
export default {
	components:{
		list,
	},
	name:'bcontent',
	data(){
		return {
			data:[],
			pulldown:true,
			showdata:[]
		}
	},
	created(){
		this.loadData(),
		this.floor()
	},
	mounted(){
		this.addList()
	},
	methods:{
		loadData(){
			axios.get("/index").then((res)=>{
				console.log(res.data.list)
				this.data=res.data.list.concat(this.data)
			}).then(()=>{
				this.floor()
			}).then(()=>{
				this.showList()
			})
		},
		floor(res){
			res=res / 10000;
			return	res.toFixed(1);
		},
		addList(){
			window.addEventListener("scroll",()=>{
				if(!isAdd){return}
				isAdd=false;
				setTimeout(()=>{
					doc=document.html||document.documentElement;
					isAdd=true;
					dis=((doc.offsetHeight-doc.scrollTop)/doc.offsetHeight)*10|0;
					if(dis<=4&&this.data.length){
						this.showList()
					}
				})
			},1000)
		},
		showList(){
			let con =this.data.splice(0,listNum)
			this.showdata=this.showdata.concat(con)
		},
	},
}
</script>

<style>

</style>